using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class UIEC_Button2_Script : MonoBehaviour,
    IBeginDragHandler, IDragHandler, IEndDragHandler
{
    public void OnBeginDrag(PointerEventData eventData)
    {
        Debug.Log("开始拖拽...");
        // 拖拽开始时, 当前对象的 射线检测raycast target设置为false
        GetComponent<Image>().raycastTarget = false;
    }

    public void OnDrag(PointerEventData eventData)
    {
        Debug.Log("raycast object: "+eventData.pointerEnter);
        // 实现拖拽
        transform.position = Input.mousePosition;
    }

    public void OnEndDrag(PointerEventData eventData)
    {
        Debug.Log("拖拽结束...");
        GetComponent<Image>().raycastTarget = true;
    }
}